/*
 * Copyright (c) 2013 WDCY Information Technology Co. Ltd
 * www.wdcy.cc
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * WDCY Information Technology Co. Ltd ("Confidential Information").
 * You shall not disclose such Confidential Information and shall use
 * it only in accordance with the terms of the license agreement you
 * entered into with WDCY Information Technology Co. Ltd.
 */
package com.monkey.web.dto.response.role;


import com.monkey.core.domain.permission.Permission;
import com.monkey.core.domain.resource.Menu;
import com.monkey.core.domain.role.RoleResourcePermission;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Wu Tianqiang
 */
public class ResourcePermissionJSONDto {
    private Long resourceId;
    private String resourceName;
    private String resourceIdentity;

    private Long permissionId;
    private String permissionName;
    private String permission;

    public ResourcePermissionJSONDto(RoleResourcePermission roleResourcePermission) {
        Menu menu = roleResourcePermission.getMenu();
        this.resourceId = menu.getId();
        this.resourceName = menu.getName();
        this.resourceIdentity = menu.getIdentity();

        Permission permission = roleResourcePermission.getPermission();
        this.permissionId = permission.getId();
        this.permissionName = permission.getName();
        this.permission = permission.getPermission();
    }

    public static List<ResourcePermissionJSONDto> toJSONDto(List<RoleResourcePermission> roleResourcePermissions) {
        List<ResourcePermissionJSONDto> resourcePermissionJSONDtos = new ArrayList<>();
        for (RoleResourcePermission roleResourcePermission : roleResourcePermissions) {
            resourcePermissionJSONDtos.add(new ResourcePermissionJSONDto(roleResourcePermission));
        }
        return resourcePermissionJSONDtos;
    }


    public Long getResourceId() {
        return resourceId;
    }

    public void setResourceId(Long resourceId) {
        this.resourceId = resourceId;
    }

    public Long getPermissionId() {
        return permissionId;
    }

    public void setPermissionId(Long permissionId) {
        this.permissionId = permissionId;
    }

    public String getResourceName() {
        return resourceName;
    }

    public void setResourceName(String resourceName) {
        this.resourceName = resourceName;
    }

    public String getResourceIdentity() {
        return resourceIdentity;
    }

    public void setResourceIdentity(String resourceIdentity) {
        this.resourceIdentity = resourceIdentity;
    }

    public String getPermissionName() {
        return permissionName;
    }

    public void setPermissionName(String permissionName) {
        this.permissionName = permissionName;
    }

    public String getPermission() {
        return permission;
    }

    public void setPermission(String permission) {
        this.permission = permission;
    }
}